import cv2
from cgi import test
from cv2 import mean
from importlib_metadata import distribution, re
import matplotlib.pyplot as plt
import numpy as np
import math
import time
import sys
import os
import argparse
from colorama import Fore, Back, Style
from colorama import init

# load all images in the current directory
def load_images(directory):
    images = []
    filenames = []
    # for filename in os.listdir(directory):
    #     if filename.endswith(".png"):
    #         filenames.append(filename)

    for i in range(1,817):
        filenames.append(directory + "img" + str(i)+".png")

    # sort the filenames
    # filenames.sort()
    print(filenames)
    # read images
    for filename in filenames:
        # image = cv2.imread(directory + "/" + filename)
        images.append(cv2.imread(filename))

    return images

imgs = load_images("/home/t/workspace/AGI/THBI/workreport/5_14/1212/")

# for img in imgs:
#     cv2.imshow("image", img)
#     cv2.waitKey(0)

# compute the mean of each images
means = []
for img in imgs:
    means.append(np.mean(img))

# draw the mean in the form of chart
plt.plot(means)
plt.show()




